package com.ysm.smfu.adapter;

import android.content.Intent;
import android.widget.ListView;

import com.ysm.smfu.activity.DetailActivity;
import com.ysm.smfu.bean.HomeSearchResultBean;
import com.ysm.smfu.holder.BaseHolder;
import com.ysm.smfu.holder.BaseListHolder;
import com.ysm.smfu.utils.UIUtils;

import java.util.List;

/**
 * 用来处理返回数据格式类似的adapter
 */
public class BaseListAdapter extends DefaultAdapter<HomeSearchResultBean.BusinessInfo> {

    public BaseListAdapter(List<HomeSearchResultBean.BusinessInfo> datas, ListView listView, Object object) {
        super(datas, listView, object);
    }

    @Override
    protected BaseHolder<HomeSearchResultBean.BusinessInfo> getHolder() {
        return new BaseListHolder(object);
    }

    @Override
    protected void onInnerItemClick(int position) {
        if (position >= datas.size())
            return;
        // 传递过去id，调用详情接口
        Intent intent = new Intent(UIUtils.getContext(), DetailActivity.class);
        intent.putExtra("packageName", datas.get(position).id);
        intent.putExtra("distance", datas.get(position).distance);
        UIUtils.startActivity(intent);
    }
}
